package com.controller;

import com.domain.LiveEntity;
import com.dto.JsonResponse;
import com.dto.PageResult;
import com.service.LiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 直播表 前端控制器
 * </p>
 *
 * @author sly
 * @since 2023-12-23
 */
@RestController
@RequestMapping("/live")
public class LiveController {

    @Autowired
    private LiveService liveService;

    /**
     * 查询直播列表
     */
    @PostMapping("/pageListLive")
    public JsonResponse<PageResult<LiveEntity>> pageListLive(@RequestBody LiveEntity live) {
        PageResult<LiveEntity> result = liveService.pageListLive(live);
        return new JsonResponse<>(result);
    }

    /**
     * 查询直播列表
     */
    @GetMapping("/getLiveDetail")
    public JsonResponse<LiveEntity> getLiveDetail(@RequestParam Long liveId) {
        LiveEntity result = liveService.getLiveDetail(liveId);
        return new JsonResponse<>(result);
    }

    /**
     * 新增直播
     */
    @PostMapping("/addLive")
    public JsonResponse<String> addLive(@RequestBody LiveEntity live) {
        liveService.addLive(live);
        return JsonResponse.success();
    }

    /**
     * 修改直播信息
     */
    @PostMapping("/updateLive")
    public JsonResponse<String> updateLive(@RequestBody LiveEntity live) {
        liveService.updateLive(live);
        return JsonResponse.success();
    }

    /**
     * 删除直播
     */
    @GetMapping("/deleteLive")
    public JsonResponse<String> deleteLive(@RequestParam Long liveId) {
        liveService.deleteLive(liveId);
        return JsonResponse.success();
    }

}
